using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations.Schema;
using SalesPages.DomainModel;

namespace SalesPages.EntityFrameworkRepository.Mapping
{
    public class RioQuizHistoryMap : EntityTypeConfiguration<RioQuizHistory>
    {
        public RioQuizHistoryMap()
        {
            // Primary Key
            this.HasKey(t => new { t.RioUserId, t.RioQuizId });

            // Properties
            this.Property(t => t.RioUserId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.RioQuizId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Answer)
                .IsRequired()
                .IsFixedLength()
                .HasMaxLength(1);

            // Table & Column Mappings
            this.ToTable("RioQuizHistory");
            this.Property(t => t.RioUserId).HasColumnName("RioUserId");
            this.Property(t => t.RioQuizId).HasColumnName("RioQuizId");
            this.Property(t => t.Answer).HasColumnName("Answer");
            this.Property(t => t.IsCorrect).HasColumnName("IsCorrect");
            this.Property(t => t.CreatedDate).HasColumnName("CreatedDate");
        }
    }
}
